home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performSound.mel1 < prev    next >
Encoding:
Text File  |  2003-07-17  |  5.8 KB  |  213 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  Dec. 17/96
  22. //  Author:         clm
  23. //
  24. //  Description:
  25. //      Option box dialog for each of the sound entries in the Display->sound
  26. //    sub-menu.
  27. //
  28. //  Input Arguments:
  29. //      int showOptionBox        true - show the option box dialog
  30. //                                false - just execute the command
  31. //
  32. //        string node                name of audio node to edit
  33. //
  34. //  Return Value:
  35. //      None.
  36. //
  37.  
  38. proc
  39. setOptionVars (int $forceFactorySettings, string $node)
  40. {
  41.     // Since this option box is not for creating new objects, but rather
  42.     // editing an existing object, then we always want to set up the
  43.     // option vars to have the current values of the sound node.
  44.     // If $forceFactorySettings is true, we will reset the offset to 0.
  45.     //
  46.     optionVar -stringValue soundFileName `sound -query -file $node`;
  47.  
  48.     if ($forceFactorySettings)
  49.     {
  50.         optionVar -floatValue soundStartTime 0.0;
  51.     }
  52.     else
  53.     {
  54.         optionVar -floatValue soundStartTime `sound -query -offset $node`;
  55.     }
  56. }
  57.  
  58. proc
  59. editSoundNode(string $node)
  60. {
  61.     sound -edit -offset `optionVar -query soundStartTime` $node;
  62.  
  63.     $filename = `optionVar -query soundFileName`;
  64.  
  65.     // Only display the sound if it's vaild.  Otherwise, we'd remove the currently
  66.     // displayed sound when we selected an audio node with an invalid filename.
  67.     //
  68.     if( !catch( `sound -edit -file $filename $node` ) ) {
  69.         setSoundDisplay($node, 1);
  70.     } 
  71. }
  72.  
  73.  
  74. global proc
  75. soundSetup (string $parent, int $forceFactorySettings, string $node)
  76. {
  77.     // Retrieve the option settings
  78.     //
  79.     setOptionVars ($forceFactorySettings, $node);
  80.  
  81.     setParent $parent;
  82.  
  83.     // Query the optionVar's and set the values into the controls
  84.  
  85.     textFieldGrp -edit -fileName `optionVar -query soundFileName` file;
  86.  
  87.     floatFieldGrp -edit -value1 `optionVar -query soundStartTime` offset;
  88. }
  89.  
  90. global proc
  91. soundCallback (string $parent, string $node)
  92. {
  93.     setParent $parent;
  94.  
  95.     // Set the optionVar's from the control values, and then perform the command
  96.  
  97.     optionVar -stringValue soundFileName `textFieldGrp -query -fileName file`;
  98.  
  99.     optionVar -floatValue soundStartTime `floatFieldGrp -query -value1 offset`;
  100.  
  101.     editSoundNode $node;
  102.  
  103.     if( `textFieldGrp -exists file`    ) {
  104.         textFieldGrp -edit -fileName `sound -query -file $node` file;
  105.     }
  106. }
  107.  
  108. global proc int
  109. soundUpdateFilename(string $filename, string $fileType)
  110. {
  111.     textFieldGrp -edit -fileName $filename file;
  112.     return 1;
  113. }
  114.  
  115. proc string
  116. soundTabPage (string $tabLayout)
  117. {
  118.     setParent $tabLayout;
  119.  
  120.     string $tabForm = `columnLayout -adjustableColumn true`;
  121.  
  122.     textFieldGrp -l "Sound file" file;
  123.     button -l "Browse..."
  124.         -c "fileBrowser \"soundUpdateFilename\" \"Accept\" \"\" 0" browser;
  125.  
  126.     floatFieldGrp -l "Start time" -numberOfFields 1 offset;
  127.  
  128.     return $tabForm;
  129. }
  130.  
  131. proc
  132. soundOptions (string $node)
  133. {
  134.     string $commandName = "sound";
  135.  
  136.     string $optionBoxTitle = ("\""+$node+"\" sound options");
  137.  
  138.     string $applyTitle = "Sound";
  139.  
  140.     // Build the option box "methods"
  141.     //
  142.     string $callback = ($commandName + "Callback");
  143.     string $setup = ($commandName + "Setup");
  144.  
  145.     // Build the window, with a tab layout
  146.     //
  147.     setUITemplate -pushTemplate DefaultTemplate;
  148.     string $widgetList[] = `getStandardWindow $optionBoxTitle 1 "noOptions"`;
  149.  
  150.     // Make the form invisible while we create the widgets in the window
  151.     //
  152.     formLayout -e -vis false $widgetList[1];
  153.  
  154.     // Attach each tab
  155.     //
  156.     string $tabPage = `soundTabPage $widgetList[2]`;
  157.  
  158.     tabLayout -edit
  159.         -tabLabel $tabPage "Basic" 
  160.         $widgetList[2];
  161.  
  162.     // Attach the standard buttons
  163.     //
  164.     string $buttonList[] = `addStandardButtons $commandName $applyTitle
  165.                                     $widgetList[1] $widgetList[2] "noOptions"`;
  166.  
  167.     // attach commands to the standard buttons
  168.     //
  169.     button -edit -command ("deleteUI " + $widgetList[0]) $buttonList[3];
  170.     button -edit -command ("deleteUI " + $widgetList[0]) $buttonList[2];
  171.     button -edit -command ($setup + " " + $widgetList[0] + " true " + $node)
  172.                                                                 $buttonList[1];
  173.     button -edit -command ($callback + " " + $widgetList[0] + " " + $node)
  174.                                                                 $buttonList[0];
  175.  
  176.     // Make the form layout visible so we can see what we built, and
  177.     // reset the template
  178.     //
  179.     formLayout -e -vis true $widgetList[1];
  180.     setUITemplate -popTemplate;
  181.  
  182.     // Fill out the help menu item
  183.     //
  184.     if( size( $widgetList ) > 3 ) {
  185.         string $helpMenuText = `menuItem -q -l $widgetList[3]`;
  186.         $helpMenuText = $helpMenuText + $commandName;
  187.         menuItem -e -l $helpMenuText 
  188.                  -c ("help -doc " + $commandName) $widgetList[3];
  189.     }
  190.  
  191.     // Call the setup "method" to fill in the current settings
  192.     //
  193.     eval (($setup + " " + $widgetList[0] + " false " + $node));    
  194.     showWindow $widgetList[0];
  195. }
  196.  
  197. global proc
  198. performSound (int $showOptionBox, string $node)
  199. {
  200.     if ($showOptionBox) {
  201.         soundOptions($node);
  202.     }
  203.     else {
  204.         // Retrieve the option settings
  205.         //
  206.         setOptionVars (false, $node);
  207.  
  208.         // Execute the command with the option settings
  209.         //
  210.         editSoundNode $node;
  211.     }
  212. }
  213.